<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .v-move, .list-move {
        transition: transform 2s;
      }
    </style>
  </head>
  <body>
    <div id="flip-list-demo" class="demo">
      <button v-on:click="shuffle">随机打乱</button>
      <!-- transitiongroup 检测到 内部的元素位置发生改变， 可以给元素上添加v-move类名  （FLIP） -->
      <transition-group name="list" tag="ul">
        <li v-for="item in items" v-bind:key="item">{{ item }}</li>
      </transition-group>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
    <script>
      // 表单操作 可以直接利用v-model指令绑定表单项，动态获取用户输入的内容
      var vm = new Vue({
        el: "#flip-list-demo",
        data: {
          items: [1, 2, 3, 4, 5, 6, 7, 8, 9],
        },
        methods: {
          shuffle: function () {
            // shuffle() 方法将序列的所有元素随机排序。
            this.items = _.shuffle(this.items);
          },
        },
      });
    </script>
  </body>
</html>